home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / CustomNew.cp / info.txt < prev   
Text File  |  2014-09-28  |  2KB  |  40 lines

  1. Subject:  CustomNew.cp
  2. Author:  Francois Pottier
  3. Uploaded By:  AFC Radix1
  4. Date:  11/19/1995
  5.  
  6. File:  CustomNew.cp (8383 bytes) 
  7. Estimated Download Time (60658 baud):  < 1 minute
  8. Download Count:  101
  9.  
  10. Needs:  C++ compiler
  11.  
  12. Keywords:  C++ OPERATOR NEW DELETE MEMORY MALLOC
  13.  
  14.  
  15. LIBRARY:   MDV/Developer Source Code/C++
  16. KEYWORDS:  C++ OPERATOR NEW DELETE MEMORY MALLOC
  17.  
  18. A replacement for the global operator new and operator delete implementations. From the comments in the code:
  19. -----
  20. Advantages over MetroWerks's definition:
  21. 1. Memory is taken from the application heap or the temporary heap (preferrably the first) for greater flexibility.
  22. 2. Unused memory pools are released to the system.
  23. 3. Less fragmentation, because the MetroWerks delete operator doesn't always join adjacent free blocks.
  24. 4. If pool allocation fails, new doesn't revert to calling NewPtr for each block. It's a good thing, because otherwise the program would just slow down to a crawl (NewPtr is much slower than new) and die a horrible death, should the Toolbox run out of space.
  25.  
  26. Finally, I keep a count of used blocks and free blocks, which can help assess the program's memory usage and fragmentation.
  27. -----
  28. I have used this code in my own projects and it works beautifully. The source is easy to read and gives you a good starting point for tinkering with the global allocator, or gathering statistics for tuning & debugging.
  29.  
  30. Posted with permission from the author. According to him the code can be freely used and distributed, but he asks that his name and email address are left in the source file.
  31.  
  32. Gregory Jorgensen
  33. MDV Forum Consultant
  34.  
  35. ------------------------------------------------------------
  36. Macintosh Developers Forum Libraries         Go Keyword: MDV
  37.  
  38. This file has been checked for viruses with Disinfectant 3.6
  39.  
  40.